<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
 ?>
<?= Html::cssFile('./css/course/bootstrap.css')?>
<?= Html::cssFile('./css/course/common.css')?>
<?= Html::cssFile('./css/course/bootstrap-extends.css')?>
<?= Html::cssFile('./css/course/class-default.css')?>
<?= Html::cssFile('./css/course/web.css')?>
<?= Html::cssFile('./css/course/member.css')?>
<?= Html::cssFile('./css/course/font-awesome.min.css')?>

<?= Html::cssFile('./assets/css/uploadsoft.css')?>
<?= Html::jsFile('./assets/uploadsoft/jquery.min.js')?>
<?= Html::jsFile('./assets/uploadsoft/jquery.form.js')?>
<?= Html::jsFile('./assets/js/uploadsoft2.js')?>
  <div id="content-container" class="container">

<div class="row row-12">
  <div class="col-md-12">
    <div class="panel panel-default  course-header">
      <div class="panel-body clearfix">
        <a href="http://localhost/eudsoho/web/app.php/course/2">
            <?php if($course['course_thumb']){?>
                <img class="picture" src="<?php echo 'http://files.bwphp.com/file/image/show/110/60?path='.$course['course_thumb']?>">
            <?php }else{?>
            <img class="picture" src="./css/course/coursePicture">
            <?php }?>
        </a>

        <h1 class="title"><a href="http://localhost/eudsoho/web/app.php/course/2">
                <?php echo $course['course_name']; ?></a>
                      <span class="label label-warning "><?php if ($course['status'] == 0) {
                        echo '未发布';
                      }elseif ($course['status'] == 1) {
                        echo "已发布";
                      }elseif ($course['status'] == 2) {
                        echo "已关闭";
                      } ?></span>
                  </h1>

        <div class="teachers">
             教师：
             <a href="http://localhost/eudsoho/web/app.php/course/2/manage/base#modal" data-toggle="modal" data-url="/eudsoho/web/app.php/course/2/teacher/1"><?php echo $course['teacher']['teacher_name']  ?></a>
        </div>
        <!-- <div class="toolbar hidden-xs hidden-lt-ie8">
            <div class="btn-group">
              <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">预览 <span class="caret"></span></button>
              <ul class="dropdown-menu pull-right">
                  <li><a href="http://localhost/eudsoho/web/app.php/course/2?previewAs=member" target="_blank">作为 已购买用户</a></li>
                  <li><a href="http://localhost/eudsoho/web/app.php/course/2?previewAs=guest" target="_blank">作为 未购买用户</a></li>
              </ul>
            </div>
            <div class="btn-group">
                <button class="btn btn-success btn-sm course-publish-btn" data-url="/eudsoho/web/app.php/course/2/manage/publish">发布课程</button>
             </div>
        </div> -->
      </div>
    </div>
  </div>
</div>

<div class="row">
  <div class="col-md-3">
                <div class="panel panel-default">
       <div class="panel-body">
          <div class="list-group-panel">
			<?php echo $this->render('_leftnav') ?>
      </div>
      </div>
<div class="col-md-9">
	<div class="panel panel-default panel-col">
		<div class="panel-heading">
		课程图片
		</div>
		<!-- 显示图片 -->

	<div class="panel-body">
		<?php
			$form = ActiveForm::begin([
				'options' => ['enctype' => 'multipart/form-data',
				'class' => 'form-horizontal',
				'id'=>'course-base-form'],
				'method'=>'post',
				'action'=>'/index.php?r=course/coursefile',
				'fieldConfig' => [
					'template' => '<div class="form-group"><div class="col-md-8 controls">{input}{error}</div></div>'
				],
			]);
		?>
			<div class="form-group clearfix choose" id="old">
				<div class="col-md-offset-2 col-md-8 controls">
				<?php if ($course['course_thumb']) { ?>
					<img class="picture" id="course_picture" src="<?php echo 'http://files.bwphp.com/file/image/show/275/175?path='.$course['course_thumb']?>">

				<?php }else{?>
					<img class="picture" id="course_picture" src="./css/course/coursePicture">

				<?php } ?>

            </div>
			</div>
			<!-- <div class="form-group clearfix ">
				<div class="col-md-offset-2 col-md-8 controls">
					<p class="help-block">你可以上传jpg, gif, png格式的文件, 图片建议尺寸至少为480x270。<br>文件大小不能超过<strong>2M</strong>。</p>
				</div>
			</div>
			<div class="form-group clearfix">
				<div class="col-md-offset-2 col-md-8 controls">

				</div>
			</div> -->
			<div class="form-group" style="margin-left:100px" >
				<p class="help-block">你可以上传jpg, gif, png格式的文件, 图片建议尺寸至少为480x270。<br>文件大小不能超过<strong>2M</strong>。</p>

		       <?= $form->field($model, 'course_id', ['template'=>'{input}'])->hiddenInput(['value'=>$course['course_id']]) ?>
			   <?= $form->field($model, 'course_thumb', ['template'=>'{input}'])->hiddenInput(['id'=>'course_thumb']) ?>
			   <div class="btn" style="">
		            <span>添加课程封面</span>
		             <?= Html::fileInput('filedata','', ['id'=>'fileupload']) ?>
		        </div>
		        <div class="progress" style='margin-left:280px'>
		    		<span class="bar"></span><span class="percent">0%</span >
				</div>
		        <div class="files" style='margin-left:136px'></div>
		        <div id="showimg"></div>
			</div>
			<div class="modal-footer">
				<?= Html::submitButton('上传', ['class' => 'btn btn-success']) ?>
			</div>
		<?php ActiveForm::end(); ?>
	</div>
	<!-- 上传图片 -->
</div>
<!-- /container -->

  <div class="site-footer container clearfix">

    <ul class="site-footer-links">
	</ul>


<style>
     .choose img{
        width:460px;
        height: 280px;
    }

</style>
<script type="text/javascript">
	 $("#change_img").change(function() {
        var file = document.getElementById("change_img").files[0];
        console.log(file);
        var tmpimg=document.createElement('img');
        tmpimg.src=window.URL.createObjectURL(file);

        $('.choose').replaceWith("<div class='new choose' style='padding-left:140px'><div class='col-md-offset-2 col-md-8 controls'></div></div>");
        $("#old").hide();
        $(".new").html(tmpimg);

    });
</script>